package com.qf.administration.controller;

import com.github.pagehelper.PageInfo;
import com.qf.administration.qo.CarSortQO;
import com.qf.administration.service.CarSortService;
import com.qf.administration.vo.CarSortVO;
import com.qf.common.base.result.RespResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Title: CarSortController
 * @Description:
 * @author:ZWX
 * @date: 2023/5/23 20:39
 */
@Api(tags = "车辆分类管理")
@RestController
@RequestMapping("/carsort")
public class CarSortController {
    @Resource
    private CarSortService carSortService;

    @ApiOperation("添加车辆类别信息")
    @PostMapping("/add")
    @ApiResponses({@ApiResponse(code = 200, message = "成功")})
    public RespResult<String> addCarSort(@RequestBody CarSortQO carSortQO) {
        return carSortService.addCarSort(carSortQO);
    }

    @ApiOperation("伪删除车辆类别信息")
    @PutMapping("/delete")
    public RespResult<String> deleteCarSort(@RequestParam int[] ids) {
        return carSortService.deleteCarSort(ids);
    }

    @ApiOperation("修改车辆类别信息")
    @PutMapping("/update")
    public RespResult<String> updateCarSort(@RequestBody CarSortQO carSortQO) {
        return carSortService.updateCarSort(carSortQO);
    }

    @ApiOperation("查询车辆类别信息")
    @GetMapping("/list")
    public RespResult<PageInfo<CarSortVO>> queryCarSort(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int size, @RequestParam(required = false) String busNumber, @RequestParam(required = false) String carSortName) {
        return RespResult.success(carSortService.queryCarSort(page, size, carSortName));
    }

    @ApiOperation("查询车辆类别单条信息")
    @GetMapping("/one")
    public CarSortVO queryCarSortOne(@RequestParam int id) {
        return carSortService.queryCarSortOne(id);
    }
}
